package q1656_OrderedStream;

import java.util.ArrayList;
import java.util.List;

public class OrderedStream {
    int ptr;
    String[] myStream;
    public OrderedStream(int n) {
        // size = n + 1;
        myStream = new String[n + 1];
        // Arrays.fill(myStream, "None");
        ptr = 1;
    }

    public List<String> insert(int idKey, String value) {
        List<String> res = new ArrayList<>();
        myStream[idKey] = value;
        while (ptr < myStream.length && myStream[ptr] != null) {
            res.add(myStream[ptr++]);
        }
        return res;
    }
}
